package UDP回显服务器;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

public class UDPDictionaryService extends UDPService{
    private Map<String, String> dict = new HashMap<>();
    public UDPDictionaryService(int port) throws SocketException {
        super(port);
        dict.put("cat","猫");
        dict.put("dog","狗");
        dict.put("bird","鸟");
        dict.put("cxk","鸡");
    }
    @Override
    public String process(String request) {
        return dict.getOrDefault(request,"这个词咱也不知道呀！");
    }

    public static void main(String[] args) throws IOException {
        UDPDictionaryService dictionaryService=new UDPDictionaryService(8000);
        dictionaryService.start();
    }
}
